import { CoolCommException } from "@cool-midway/core";
import { Rule, RuleType } from "@midwayjs/validate";
import { ModuleType } from "../entity/profile";
import { CommonAuditStatus } from "../../../interface";

export class AddProviderDTO {
    @Rule(RuleType.string().required().error(new CoolCommException('手机号不能为空')))
    phone: string;

    @Rule(RuleType.string().required().error(new CoolCommException('姓名不能为空')))
    name: string

    @Rule(RuleType.number().required().error(new CoolCommException('性别不能为空')))
    gender: number;

    @Rule(RuleType.string().required().error(new CoolCommException('照片不能为空')))
    photo: string;

    @Rule(RuleType.string().required().error(new CoolCommException('常驻地不能为空')))
    residence: string;

}

export class UpdateProviderMemberDTO {
    @Rule(RuleType.number().required().error(new CoolCommException('服务人员ID不能为空')))
    providerId: number;

    @Rule(RuleType.string().optional().allow('').error(new CoolCommException('姓名格式不正确')))
    name?: string;

    @Rule(RuleType.number().valid(0, 1).optional().error(new CoolCommException('性别格式不正确')))
    gender?: number;

    @Rule(RuleType.number().optional().min(0).max(120).error(new CoolCommException('年龄格式不正确')))
    age?: number;

    @Rule(RuleType.string().optional().allow('').error(new CoolCommException('头像格式不正确')))
    photo?: string;

    @Rule(RuleType.string().optional().allow('').error(new CoolCommException('常驻地格式不正确')))
    residence?: string;

    @Rule(RuleType.number().optional().min(0).max(70).error(new CoolCommException('从业年限格式不正确')))
    experienceYears?: number;

    @Rule(RuleType.number().optional().min(0).max(70).error(new CoolCommException('驾龄格式不正确')))
    drivingYears?: number;

    @Rule(RuleType.number().optional().min(0).error(new CoolCommException('服务次数格式不正确')))
    serviceCount?: number;

    @Rule(RuleType.number().optional().min(0).max(5).precision(1).error(new CoolCommException('综合评分格式不正确')))
    comprehensiveScore?: number;

    @Rule(RuleType.string().optional().allow('').max(500).error(new CoolCommException('介绍不能超过500个字符')))
    introduction?: string;

    @Rule(RuleType.array().items(RuleType.string().required()).optional().error(new CoolCommException('服务范围格式不正确')))
    serviceScope?: string[];

    @Rule(RuleType.object().keys({
        primaryColor: RuleType.string().optional(),
        secondaryColor: RuleType.string().optional(),
        backgroundColor: RuleType.string().optional(),
        backgroundImage: RuleType.string().optional().allow('').allow(null),
        fontColor: RuleType.string().optional(),
    }).optional())
    style?: {
        primaryColor?: string;
        secondaryColor?: string;
        backgroundColor?: string;
        backgroundImage?: string | null;
        fontColor?: string;
    };

    @Rule(RuleType.array().items(RuleType.string().required()).optional().error(new CoolCommException('展示模块格式不正确')))
    displayModule?: ModuleType[];

    @Rule(RuleType.string().optional().allow('').max(500).error(new CoolCommException('服务内容不能超过500个字符')))
    serviceContent?: string;
}

export class UpdatePartnerRelationDTO {
    @Rule(RuleType.number().required().error(new CoolCommException('服务人员ID不能为空')))
    providerId: number;

    @Rule(
        RuleType.number()
            .valid(
                CommonAuditStatus.PENDING,
                CommonAuditStatus.APPROVED,
                CommonAuditStatus.REJECTED,
                CommonAuditStatus.NORMAL,
                CommonAuditStatus.DISABLED
            )
            .required()
            .error(new CoolCommException('合作状态不合法'))
    )
    status: CommonAuditStatus;
}
